﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Zatify.WebUI.Admin.Helpers
{
    public static class Helper
    {
        public static List<SelectListItem> GetBusinessHoursSelectList(TimeSpan selected)
        {
            var time = new DateTime(2000, 1, 1, 0, 0, 0);
            var timeFormat = "hh:mm tt";
            var timeInterval = 30;

            var businessHours = new List<SelectListItem>();

            for (int i = 0; i < 48; i++)
            {
                businessHours.Add(new SelectListItem()
                {
                    Text = time.ToString(timeFormat, System.Globalization.CultureInfo.InvariantCulture),// time.TimeOfDay.ToString(),
                    Value = time.TimeOfDay.ToString(),
                    Selected = (time.TimeOfDay == selected)
                });

                time = time.AddMinutes(timeInterval);
            }

            return businessHours;
        }

        public static List<SelectListItem> GetBusinessHoursSelectList()
        {
            return GetBusinessHoursSelectList(DateTime.Now.TimeOfDay);
        }
    }
}